#!/usr/bin/ruby

require 'tk'

msg="贪吃贪睡的大熊猫"
root=TkRoot.new{title msg}
label_msg=TkLabel.new(root){
    text  msg;
    pack :padx=>2,:pady=>2,:side=>'top';
    font "arial 20 bold"
}

var = TkVariable.new
TkEntry.new(root){
	text var
	pack
}
TkEntry.new(root){
	text var
	pack
}
TkButton.new(root,text:"改变颜色"){
	pack padx:2,pady:2,side:'bottom'
	command{
		color = label_msg.cget("foreground");
		print "color is #{color}"
		if(color=="#000000" or color=="black")
			label_msg.configure(foreground:'red')
		else
			label_msg.configure(foreground:"black")
		end
	}
}

label_msg.bind("Enter") {label_msg.configure(foreground:'#666666')}
label_msg.bind("Leave") {label_msg.configure(foreground:'black')}
label_msg.bind("Control-ButtonRelease-1") {label_msg.configure(foreground:'#996699')}
Tk.mainloop